package com.wufan.day05.exer2;

/**
 * @author SongWufan
 * @date 2021/3/10 22:13
 */
public class Account {
    private double balance;

    public Account(double init_balance) {
        this.balance = init_balance;
    }

    public double getBalance() {
        return balance;
    }

    /**
     * 存钱
     *
     * @param amt
     */
    public void deposit(double amt) {
        if (amt > 0) {
            balance += amt;
            System.out.println("存钱成功");
        }
    }

    /**
     * 取钱
     * @param amt
     */
    public void withdraw(double amt) {
        if (balance >= amt) {
            balance -= amt;
            System.out.println("取钱成功");
        }
        else {
            System.out.println("余额不足");
        }
    }

}
